package com.gopay.common.core.file.dao.impl;

import java.io.Serializable;
import java.util.List;
import java.util.Map;

import org.apache.commons.lang3.StringUtils;
import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Order;
import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Repository;

import com.gopay.common.base.dao.impl.BaseDAOImpl;
import com.gopay.common.core.file.dao.FileUploadDtlDAO;
import com.gopay.common.domain.file.FileUploadDtl;

/**
 * 文件上传流水表DAO实现类
 * @FileUploadDtlDAOImpl.java
 * @author Light
 * @2016年6月3日 上午11:18:05  www.gopay.com.cn Inc.All rights reserved.
 */
@Repository(value="fileUploadDtlDAO")
public class FileUploadDtlDAOImpl extends BaseDAOImpl<FileUploadDtl, Serializable> implements FileUploadDtlDAO {

    @Override
    public FileUploadDtl get(Serializable id) {
        return super.find(FileUploadDtl.class, id);
    }

    @Override
    public List<FileUploadDtl> get(Map<Object, Object> paraMap) {
        DetachedCriteria criteria = DetachedCriteria.forClass(FileUploadDtl.class);
        if(StringUtils.isNotEmpty((String)paraMap.get("id"))){
            criteria.add(Restrictions.eq("id", paraMap.get("id")));
        }
        if(StringUtils.isNotEmpty((String)paraMap.get("custId"))){
            criteria.add(Restrictions.eq("custId", paraMap.get("custId")));
        }
        if(StringUtils.isNotEmpty((String)paraMap.get("category"))){
            criteria.add(Restrictions.eq("category", paraMap.get("category")));
        }
        if(StringUtils.isNotEmpty((String)paraMap.get("isDelete"))){
            criteria.add(Restrictions.eq("isDelete", paraMap.get("isDelete")));
        }
        if(StringUtils.isNotEmpty((String)paraMap.get("platform"))){
            criteria.add(Restrictions.eq("platform", paraMap.get("platform")));
        }
        if(StringUtils.isNotEmpty((String)paraMap.get("desc"))){
            criteria.addOrder(Order.desc((String) paraMap.get("desc")));            
        }
        return super.findByCriteria(criteria);
    }

    @Override
    public void saveFileUploadDtl(FileUploadDtl fileUploadDtl) {
        super.save(fileUploadDtl);
    }

    @Override
    public void updateFileUploadDtl(FileUploadDtl fileUploadDtl) {
        super.update(fileUploadDtl);
    }

}
